<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Admin\Controller;
use Think\Controller;
class AuthController extends Controller {
    function index(){
        $this -> display();
    }

    function showlist(){
        $admin = new \Admin\Model\AdminModel(auth);
        $info = $admin->adminList();
        $this->assign('auth',$info);
        $this->display();
    }
	function add(){
		if(empty($_POST)){
			$info = D('Auth')->where('level = 0')->select();
			$this->assign('list',$info);
			$this->display();
			}else{
				$info = D('Auth')->add($_POST);
				if($info>0){
					$this->success('添加成功');
				}else{
					$this->error('添加失败');
				}
				}
		}
	function dele(){
		$where['id']=$_GET['id'];
		$dele = D('Auth')->where($where)->delete();
			if($dele){
				$this->success('删除成功');
				}else{
					$this->error('删除失败');
			}
		}
	function update(){
		if(empty($_POST)){
			$info = D('Auth')->where('level = 0')->select();
			$this->assign('list',$info);
			$where['id']=$_GET['id'];
			$i = D('Auth')->where($where)->select();
			$this->assign('show',$i);
			$this->display();
		}else{
				 $where['id'] = $_POST['id'];				
        		 $info = D('Auth')->where($where)->save($_POST);
				 
				if($info>0){
					$this->success('修改成功');
				}else{
					$this->error('修改失败');
			   }
			}
		}
}

